// pages/canvas/index.js
const app = getApp();
var getPhoteFrameList = require("../../utils/getPhoteFrame");
var WXlogin = require("../../utils/login")
var imgageMapList = new Map([])

Page({
  /**
   * 页面的初始数据
   */
  data: {
    canvasNode: null,
    ctx: null,
    dpr: 1,
    sysInfo: null,
    imgSrc: null,
    dw: 210, //宽度
    dh: 310, //高度
    _left: -9999999,
    imageList: [],
    currentImgResultObj: {},
    currentImageBgBool: false,
    originImgObj: {},
    isLoading: false,
    currentColor: "white",
    frameSrcs: [], // 图片相框
    frameId: "",
    showFrameSrcs: false, // 展示相框
    currentFrameObj: {},
    frame_path: "http://www.shazhibin.top/frame_path",
    inputValue1: "",
    inputValue2: "",
    addBtnFlag: true,
    textZindex: false,
    modalHidden: true,
    okUrl: "",
    okText: "",
    templateCanvasNode: null,
    templateCtx: null,
    templateDpr: "",
    noEdgeImgUrl: "",
    saveLoading: false,
    fontArr: [[{id:"SimSun",name:'宋体'},
              {id:"SimHei",name:'黑体'},
              {id:"KaiTi",name:'楷体'},
              {id:"STXingkai",name:'常规字体'}],
              [{id:"66px",name:'大号字体'},
              {id:"58px",name:'中号字体'},
              {id:"50px",name:'小号字体'}]],
    fontSize:"58px",
    fontfamily:"STXingkai"

  },
  onShow() {
    if (!this.data.frameSrcs.length) {
      this.getFrameList()
    }
  },

  bindMultiPickerChange: function (e) {

    let {fontArr} = this.data;
    let checkedVal =  e.detail.value;
    console.log(fontArr[0][checkedVal[0]].id,fontArr[1][checkedVal[1]].id,"picker发送选择改变，携带值为")
    this.setData({
      fontfamily: fontArr[0][checkedVal[0]].id,
      fontSize:fontArr[1][checkedVal[1]].id
    })
  },
  // bindMultiPickerColumnChange: function (e) {
  //   console.log('修改的列为', e.detail.column, '，值为', e.detail.value);
  // },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady(c) {
    this.setData({
      sysInfo: app.globalData.myDevice
    })
    const query = wx.createSelectorQuery().in(this);
    query
      .select("#testCanvas")
      .fields({
        node: true,
        size: true,
      })
      .exec((res) => {
        let canvasNode = res[0].node;
        let ctx = canvasNode.getContext("2d");
        let dpr = app.globalData.myDevice.pixelRatio;
        canvasNode.width = this.data.dw * dpr;
        canvasNode.height = this.data.dh * dpr
        this.setData({
          canvasNode,
          ctx,
          dpr,
        })
        this.data.ctx.scale(this.dpr, this.dpr);
        if (app.globalData.imgSrc) {
          this.setData({
            _left: (this.data.sysInfo.windowWidth - 210) / 2,
            imgSrc: app.globalData.imgSrc,
            addBtnFlag: false
          })
          wx.getImageInfo({
            src: app.globalData.imgSrc,
          }).then(_r => {
            console.log(76, _r);
            this.drawImage(this.data.imgSrc, 210 * dpr, 310 * dpr, 0, 0, true)
          })
        }
      });


    const query1 = wx.createSelectorQuery()
    query1.select('#tTemplatePic')
      .fields({
        node: true,
        size: true
      })
      .exec((res) => {
        const templateCanvasNode = res[0].node
        const templateCtx = templateCanvasNode.getContext('2d')
        const templateDpr = wx.getSystemInfoSync().pixelRatio

        templateCanvasNode.width = 2480;
        templateCanvasNode.height = 3508;
        this.setData({
          templateCanvasNode,
          templateCtx,
          templateDpr
        })
      })


  },
  // 上传图片
  chooseImage: function () {
    wx.navigateTo({
      url: "../canvas/cropper",
    });
  },

  //添加第一行汉字
  bindKeyInput1: function (e) {
    this.setData({
      inputValue1: e.detail.value
    })
    // let {
    //   canvasNode,
    //   ctx
    // } = this.data
    // ctx.font="30px Arial";

    // //ctx.clearRect(0, canvasNode.height - 80, canvasNode.width, 80); 
    // ctx.fillText(e.detail.value,canvasNode.width/2,canvasNode.height - 80);
    // ctx.textAlign = 'center'
  },
  //添加第二行汉字
  bindKeyInput2: function (e) {
    this.setData({
      inputValue2: e.detail.value
    })
    // let {
    //   canvasNode,
    //   ctx
    // } = this.data
    // ctx.font="30px Arial";
    // ctx.textAlign = 'center'
    // ctx.fillText(e.detail.value,canvasNode.width/2,canvasNode.height - 40);
  },

  // 绘制图片到 canvas
  drawImage(imageSrc, width, height, offectX = 0, offectY = 0, reset = true) {
    console.log(109, imageSrc, width, height, offectX, offectY, reset);
    let {
      canvasNode,
      ctx
    } = this.data
    let t = this
    this.setData({
      isLoading: true
    })
    let img = canvasNode.createImage();
    // img.width = width;
    // img.height = height;
    img.src = imageSrc;
    img.onload = function () {
      console.log("img onload");
      if (reset) {
        ctx.fillRect(0, 0, canvasNode.width, canvasNode.height)
      }
      ctx.drawImage(img, offectX, offectY, width, height);
      t.setData({
        isLoading: false
      })
    };
    img.onerror = (r) => {
      console.log("err", r);
      t.setData({
        isLoading: false
      })
    }
  },
  // 判断 imgSrc 是否存在 
  isSrcEmpty() {
    if (!this.data.imgSrc) {
      wx.showToast({
        title: "没有上传图片,不能切换"
      })
    }
  },
  // 改变颜色
  changeColor(e) {
    let {
      ctx,
      dpr,
      imgSrc,
      currentFrameObj
    } = this.data
    console.log("changeColor", imgSrc, currentFrameObj, 177, imgageMapList, ctx);
    const color = e.target.dataset.color
    if (!this.data.imgSrc) {
      wx.showModal({
        content: "没有上传图片,不能改变背景颜色",
        showCancel: false,
      })
      return false
    }
    this.setData({
      currentColor: color
    })
    if (currentFrameObj?.path) {
      ctx.fillStyle = color
      ctx.fillRect(0, 0, 210 * dpr, 310 * dpr)
      this.drawImage(this.data.imgSrc, 210 * dpr, 310 * dpr, 0, 0, false)
      setTimeout(() => {
        this.drawImage(currentFrameObj.path, 210 * dpr, 310 * dpr, 0, 0, false)
      }, 150)
    } else {
      ctx.fillStyle = color
      ctx.fillRect(0, 0, 210 * dpr, 310 * dpr)
      this.drawImage(this.data.imgSrc, 210 * dpr, 310 * dpr, 0, 0, false)
    }
  },
  // 还原图片背景
  getOriginImage(e) {
    let {
      ctx,
      dpr,
      imgSrc,
      originImgObj,
      currentFrameObj,
      currentColor
    } = this.data
    const color = e.target.dataset.color
    const removeMap = imgageMapList.get("remove")
    const cMap = imgageMapList.get(currentFrameObj.id)
    console.log("getOriginImage", 183, originImgObj, currentFrameObj, imgageMapList, removeMap, cMap);
    this.setData({
      imgSrc: originImgObj.img.path
    })
    ctx.fillStyle = "white"
    ctx.fillRect(0, 0, 210 * dpr, 310 * dpr)
    if (!imgSrc) {
      wx.showModal({
        content: "没有上传图片,还原图片背景",
        showCancel: false,
      })
      return false
    } else {
      if (cMap?.frame && currentFrameObj.id) {
        this.drawImage(originImgObj.img.path,
          210 * dpr,
          310 * dpr,
          0,
          0,
          false)
        setTimeout(() => {
          this.drawImage(currentFrameObj.path,
            cMap.frame.width * dpr,
            cMap.frame.height * dpr,
            0,
            0,
            false)
        }, 120)
        imgageMapList.set(color, {
          img: {
            ...cMap.img,
            imgSrc: originImgObj.img.path,
          },
          frame: {
            ...cMap.frame,
            path: currentFrameObj.path,
          }
        })
      } else {
        this.drawImage(originImgObj.img.path,
          210 * dpr,
          310 * dpr,
          0,
          0,
          true)
        imgageMapList.set(color, {
          img: {
            ...removeMap.img,
            imgSrc: originImgObj.img.path,
          }
        })
      }
      this.setData({
        currentImageBgBool: false
      })
    }
  },
  // 清除图片背景
  removeImageBg(e) {
    let {
      currentFrameObj,
      currentColor,
      ctx,
      imgSrc,
      dpr,
      originImgObj
    } = this.data
    const color = e.target.dataset.color;
    const currentMap = imgageMapList.get(currentFrameObj.id)
    console.log(218, imgageMapList, originImgObj, imgSrc, 192, "removeImageBg", color, currentMap, currentFrameObj, currentColor);
    this.setData({
      isLoading: true
    })
    if (!this.data.imgSrc) {
      return wx.showModal({
        content: "没有上传图片,请上传图片后重试",
        showCancel: false,
      })
    }
    if (originImgObj?.remove?.path) {
      ctx.fillStyle = currentColor
      ctx.fillRect(0, 0, 210 * dpr, 310 * dpr)
      if (currentMap) {
        this.drawImage(originImgObj.remove.path, 210 * dpr, 310 * dpr, 0, 0, false)
        setTimeout(() => {
          this.drawImage(currentFrameObj.path, 210 * dpr, 310 * dpr, 0, 0, false)
        }, 120)
        this.setData({
          currentImageBgBool: true,
          isLoading: false,
          imgSrc: originImgObj.remove.path,
          currentFrameObj: {
            ...currentFrameObj
          }
        })
        imgageMapList.set(color, {
          img: {
            imgSrc: originImgObj.remove.path,
          },
          frame: {
            path: currentFrameObj.path
          }
        })
      } else {
        this.drawImage(originImgObj.remove.path, 210 * dpr, 310 * dpr)
        imgageMapList.set(color, {
          img: {
            imgSrc: originImgObj.remove.path,
            width: 210,
            height: 310,
          }
        })
        this.setData({
          currentImageBgBool: true,
          isLoading: false,
          imgSrc: originImgObj.remove.path,
        })
      }
    } else {
      wx.uploadFile({
        filePath: this.data.imgSrc,
        name: 'file',
        url: `${app.globalData.baseUrl}/wx/photo/getForeground`,
        formData: {
          openId: app.globalData.userInfo.openId,
        },
        success: (res) => {
          let _data = JSON.parse(res.data);
          wx.getImageInfo({
            src: _data.result.picturePath,
          }).then(imgRemoveBgRes => {
            ctx.fillRect(0, 0, 210 * dpr, 310 * dpr)
            ctx.fillStyle = currentColor
            if (currentMap) {
              this.drawImage(imgRemoveBgRes.path,
                210 * dpr,
                310 * dpr,
                0,
                0,
                false)
              setTimeout(() => {
                this.drawImage(currentMap.frame.path,
                  currentMap.frame.width * dpr, currentMap.frame.height * dpr, 0, 0, false)
              }, 200)
              imgageMapList.set(color, {
                img: {
                  ...currentMap.img,
                  imgSrc: imgRemoveBgRes.path
                },
                frame: currentMap.frame
              })
              imgageMapList.set("origin", currentMap)
            } else {
              this.drawImage(imgRemoveBgRes.path, 210 * dpr, 310 * dpr, 0, 0, true)
              imgageMapList.set(color, {
                img: {
                  imgSrc: imgRemoveBgRes.path,
                  width: 210,
                  height: 310,
                }
              })
            }
            this.setData({
              originImgObj: {
                img: {
                  path: imgSrc
                },
                remove: {
                  path: imgRemoveBgRes.path
                }
              },
              imgSrc: imgRemoveBgRes.path,
              currentImageBgBool: true,
              isLoading: false
            })
            console.log("imgageMapList", imgageMapList);
          })

        },
        fail: (err) => {
          console.log(err);
          this.setData({
            isLoading: false
          })
        },
      })
    }
  },
  // 获取相框
  getFrameList() {
    let t = this
    getPhoteFrameList(this, app).then(res => {
      console.log(res, "相框")
      console.log("this.getFrameList");
      const {
        data
      } = res;
      t.setData({
        frame_path: data.result,
        frameSrcs: data.resultList,
      });
    })
  },
  toggleFrame() {
    this.setData({
      showFrameSrcs: !this.data.showFrameSrcs
    })
  },
  // 选择相框
  chooseFrame(e) {
    let {
      ctx,
      dpr,
      currentColor,
      currentImageBgBool,
      imgSrc,
      currentFrameObj
    } = this.data
    const currentFrameItem = e.currentTarget.dataset.item
    var frameId = currentFrameItem.id
    console.log(frameId, "相框id");
    wx.getImageInfo({
      src: e.currentTarget.dataset.src,
    }).then(res => {
      console.log("--", res, 289, currentImageBgBool, imgSrc, currentFrameObj);
      this.setData({
        currentFrameObj: {
          ...res,
          ...currentFrameItem
        },
        _left: (this.data.sysInfo.windowWidth - 210) / 2,
        frameId:frameId
      })
      ctx.fillStyle = currentColor
      ctx.fillRect(0, 0, 210 * dpr, 310 * dpr)
      let f_width = 210 * dpr;
      let f_height = 310 * dpr;
      this.drawImage(imgSrc, f_width, f_height, 0, 0, false)
      setTimeout(() => {
        if (imgSrc) {
          this.drawImage(res.path, 210 * dpr, 310 * dpr, 0, 0, false)

        }
      }, 120)
      setTimeout(() => {
        this.setData({
          textZindex: true
        })
      }, 800);
      imgageMapList.set(currentFrameItem.id, {
        img: {
          imgSrc,
          width: f_width,
          height: f_height,
          offsetX: 0,
          offsetY: 0
        },
        frame: {
          path: res.path,
          width: 210,
          height: 289
        }
      })
      console.log(imgageMapList);
    }).catch(() => {
      wx.hideLoading()
    })
  },
  saveImage() {
    let {
      canvasNode,
      ctx,
      inputValue1,
      inputValue2,
      imgSrc,
      fontfamily,
      fontSize
    } = this.data


    if (!imgSrc) {
      wx.showModal({
        content: "没有上传图片,请上传图片后重试",
        showCancel: false
      })
      return false
    }

    if (inputValue1) {
      ctx.textAlign = 'center'
      ctx.font = `${fontSize} ${fontfamily} bold`;
      ctx.fillStyle = "#333";
      ctx.fillText(inputValue1, canvasNode.width / 2, canvasNode.height - 50);
    }
    // if (inputValue2 && !inputValue1) {
    //   ctx.textAlign = 'center'
    //   ctx.font = "80px Arial bold";
    //   ctx.fillStyle = "#fff";
    //   ctx.fillText(inputValue2, canvasNode.width / 2, canvasNode.height - 50);
    // }
    // if (inputValue1 && inputValue2) {
    //   ctx.textAlign = 'center'
    //   ctx.font = "38px Arial bold";
    //   ctx.fillStyle = "#fff";
    //   ctx.fillText(inputValue1, canvasNode.width / 2, canvasNode.height - 78);
    //   ctx.fillText(inputValue2, canvasNode.width / 2, canvasNode.height - 28);
    // }



    let t = this;
    this.setData({
      isLoading: true
    })
    wx.canvasToTempFilePath({
      canvas: this.data.canvasNode,
    }).then(r => {
      console.log(r.tempFilePath, "图片路径")

      // this.setData({
      //   okUrl: r.tempFilePath

      // },function(){
      //   this.drawEdge();
      // })

      wx.showLoading({
        title: '加载中',
      })

      wx.uploadFile({
        filePath: r.tempFilePath,
        name: 'file',
        url: `${app.globalData.baseUrl}/wx/photo/uploadFile`,
        formData: {
          openId: app.globalData.userInfo.openId,
        },
        success: res => {
          console.log(res, "res")
          const data = res.data
          let {
            result
          } = JSON.parse(data)
          this.setData({
            okUrl: r.tempFilePath,
            okText: result.id,
            noEdgeImgUrl: result.picturePath
          }, function () {

            //this.drawEdge();
            this.drawingTemplatePic();
            var getPicParams = {
              imgUrl: result.picturePath,
              imgId: result.id
            }
            // wx.navigateTo({
            //   url: "./getPic?propParams="+JSON.stringify(getPicParams),
            // });
          })
        },
        fail: err => {
          wx.hideLoading();
          wx.showModal({
            showCancel: false,
            content: "上传失败,请稍候重试"
          })
        },
        complete: () => {
          t.setData({
            isLoading: false
          })
        }
      })
    }).catch(err => {
      console.log("err", err);
      wx.hideLoading();
      wx.showModal({
        showCancel: false,
        content: "上传失败,请稍候重试"
      })
    })
  },

  /**
   * 点击取消
   */
  modalCandel: function () {
    // do something
    this.setData({
      modalHidden: true
    })
  },

  /**
   *  点击确认
   */
  modalConfirm: function () {
    // do something
    this.setData({
      modalHidden: true
    })
  },
  mydrawRoundRect: function (cxt, x, y, width, height, radius) {
    cxt.beginPath();
    cxt.arc(x + radius, y + radius, radius, Math.PI, Math.PI * 3 / 2);
    cxt.lineTo(width - radius + x, y);
    cxt.arc(width - radius + x, radius + y, radius, Math.PI * 3 / 2, Math.PI * 2);
    cxt.lineTo(width + x, height + y - radius);
    cxt.arc(width - radius + x, height - radius + y, radius, 0, Math.PI * 1 / 2);
    cxt.lineTo(radius + x, height + y);
    cxt.arc(radius + x, height - radius + y, radius, Math.PI * 1 / 2, Math.PI);
    cxt.closePath();
  },
  // 绘制边框
  drawEdge: function () {
    let {

      noEdgeImgUrl
    } = this.data
    let that = this;

    const query2 = wx.createSelectorQuery().in(this);
    query2.select('#edgecavas')
      .fields({
        node: true,
        size: true
      })
      .exec((res) => {
        let edgeCanvas = res[0].node;
        var context = edgeCanvas.getContext("2d");
        edgeCanvas.width = 354;
        edgeCanvas.height = 524;


        var tem = edgeCanvas.createImage();
        tem.src = noEdgeImgUrl;
        tem.onload = function (e) {
          //var _canv = document.createElement('canvas');
          //this.mydrawRoundRect(context, 0, 0, 354, 524, 15);  
          var [x, y, width, height, radius] = [0, 0, 354, 524, 15]
          context.beginPath();
          context.arc(x + radius, y + radius, radius, Math.PI, Math.PI * 3 / 2);
          context.lineTo(width - radius + x, y);
          context.arc(width - radius + x, radius + y, radius, Math.PI * 3 / 2, Math.PI * 2);
          context.lineTo(width + x, height + y - radius);
          context.arc(width - radius + x, height - radius + y, radius, 0, Math.PI * 1 / 2);
          context.lineTo(radius + x, height + y);
          context.arc(radius + x, height - radius + y, radius, Math.PI * 1 / 2, Math.PI);
          context.closePath();
          context.strokeStyle = "blue";
          context.lineWidth = 30;

          context.stroke();
          context.clip()
          context.drawImage(tem, 0, 0, 354, 524);
          // console.log(canvas.toDataURL(),"图片路径")
          // context.drawImage(tem, 0, 0)


        }


        setTimeout(() => {

          // wx.canvasToTempFilePath({
          //   canvas: {
          //     x: 0,
          //     y: 0,
          //     width: 2480,
          //     height: 3508,
          //     fileType:"jpg",
          //     canvasId: 'edgecavas',
          //   }, // 使用2D 需要传递的参数
          //   success(res) {
          //     console.log(res.tempFilePath);

          //   },
          //   fail(err) {
          //     console.log(err,1111)
          //   }
          // })
          wx.canvasToTempFilePath({
            canvas: context,
          }).then(r => {
            console.log(r.tempFilePath, "图片路径+++++")
          })
          // wx.canvasToTempFilePath({
          //   x: 0,
          //   y: 0,
          //   width: 2480,
          //   height: 3508,
          //   fileType:"jpg",
          //   canvasId: 'edgecavas',
          //   success: function (res) {
          //     console.log(res.tempFilePath,"-------")
          //   },
          //   fail: function (res) {
          //     console.log(res);
          //   }
          // },that)
        }, 1000)






      })


    //var canvas = wx.createSelectorQuery("canvas");   



  },




  // 绘制模板图片
  drawingTemplatePic: function () {
    let {
      templateCanvasNode,
      templateCtx,
      okUrl,
      okText,
      frameId
    } = this.data
    let t = this

    let title = templateCanvasNode.createImage();
    let img = templateCanvasNode.createImage();
    // img.width = width;
    // img.height = height;
    img.src = okUrl;
    //img.src = "./../../images/xk.png";
    console.log(frameId,frameId == 13, "frameId")
    title.src = (frameId == 15 ? "./../../images/title2.jpg" : "./../../images/title.jpg")

    title.onload = function () {
      templateCtx.drawImage(title, 0, 0, 2480, 354);
      templateCtx.font = "58px Arial bold";
      templateCtx.fillStyle = "#333";
      templateCtx.fillText(okText, 1687, 240);
    }
    img.onload = function () {
      console.log("img onload");

      // 第一行
      templateCtx.drawImage(img, 181.6, 408, 272, 402);
      templateCtx.drawImage(img, 550, 408, 272, 402);
      templateCtx.drawImage(img, 918.4, 408, 272, 402);
      templateCtx.drawImage(img, 1286.8, 408, 272, 402);
      templateCtx.drawImage(img, 1655.2, 408, 272, 402);
      templateCtx.drawImage(img, 2023.6, 408, 272, 402);

      // 第二行
      templateCtx.drawImage(img, 181.6, 869, 272, 402);
      templateCtx.drawImage(img, 550, 869, 272, 402);
      templateCtx.drawImage(img, 918.4, 869, 272, 402);
      templateCtx.drawImage(img, 1286.8, 869, 272, 402);
      templateCtx.drawImage(img, 1655.2, 869, 272, 402);
      templateCtx.drawImage(img, 2023.6, 869, 272, 402);

      // 第三行
      templateCtx.drawImage(img, 181.6, 1330.5, 272, 402);
      templateCtx.drawImage(img, 550, 1330.5, 272, 402);
      templateCtx.drawImage(img, 918.4, 1330.5, 272, 402);
      templateCtx.drawImage(img,  1286.8, 1330.5, 272, 402);
      templateCtx.drawImage(img, 1655.2, 1330.5, 272, 402);
      templateCtx.drawImage(img, 2023.6, 1330.5, 272, 402);

      // 第四行
      templateCtx.drawImage(img, 181.6, 1792, 272, 402);
      templateCtx.drawImage(img, 550, 1792, 272, 402);
      templateCtx.drawImage(img, 918.4, 1792, 272, 402);
      templateCtx.drawImage(img, 1286.8, 1792, 272, 402);
      templateCtx.drawImage(img, 1655.2, 1792, 272, 402);
      templateCtx.drawImage(img, 2023.6, 1792, 272, 402);

      // 第五行
      templateCtx.drawImage(img, 186, 2259, 354, 524);
      templateCtx.drawImage(img, 624,2259, 354, 524);
      templateCtx.drawImage(img, 1061.4, 2259, 354, 524);
      templateCtx.drawImage(img, 1499, 2259, 354, 524);
      templateCtx.drawImage(img, 1937, 2259, 354, 524);

      // 第六行
      templateCtx.drawImage(img, 186, 2855, 354, 524);
      templateCtx.drawImage(img, 624, 2855, 354, 524);
      templateCtx.drawImage(img, 1061.4, 2855, 354, 524);
      templateCtx.drawImage(img, 1499, 2855, 354, 524);
      templateCtx.drawImage(img, 1937, 2855, 354, 524);
    };

    setTimeout(() => {
      wx.canvasToTempFilePath({
        canvas: this.data.templateCanvasNode,
      }).then(r => {
        console.log(r.tempFilePath)

        wx.uploadFile({
          filePath: r.tempFilePath,
          name: 'templateFile',
          url: `${app.globalData.baseUrl}/wx/photo/uploadTemplateFile`,
          formData: {
            openId: app.globalData.userInfo.openId,
            pictureId: okText
          },
          success: res => {
            wx.hideLoading();
            console.log(res, "res")
            var getPicParams = {
              imgUrl: okUrl,
              imgId: okText
            }
            wx.navigateTo({
              url: "../canvas/getPic?propParams=" + JSON.stringify(getPicParams),
            });
         

          },
          fail: err => {
            wx.hideLoading();
            wx.showModal({
              showCancel: false,
              content: "上传失败,请稍候重试"
            })
          },
          complete: () => {
            t.setData({
              isLoading: false
            })
          }
        
      })

    })
  },
  500)



}

});